﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Animation;
using Windows.UI.Xaml.Navigation;

// Шаблон элемента пустой страницы задокументирован по адресу http://go.microsoft.com/fwlink/?LinkId=234238

namespace Philosophy
{
    public sealed partial class Page_Question_Sprint : Page
    {     
        DispatcherTimer timer;
        DispatcherTimer timer2;
        DispatcherTimer timer_game_over;
        
        int timerCounterMin = 0;
        int timerCounterSec = 0;
        
        public Page_Question_Sprint()
        {
            this.InitializeComponent();

            timer = new DispatcherTimer();          
            timer.Tick += timer_Tick;
            timer.Interval = TimeSpan.FromSeconds(1);
            timer.Start();
            
            timer2 = new DispatcherTimer();
            timer2.Tick += timer2_Tick;
            timer2.Interval = TimeSpan.FromSeconds(61);
            timer2.Start();

            timer_game_over = new DispatcherTimer();
            timer_game_over.Tick += timer_game_over_Tick;
            timer_game_over.Interval = TimeSpan.FromMinutes(10);
            timer_game_over.Start();
        }

        void timer_Tick(object sender, object e)
        {
            if (timerCounterSec == 59)
            { timerCounterSec = 0; time_sec.Text = timerCounterSec.ToString(); }
            else { time_sec.Text = (++timerCounterSec).ToString(); }
        }

        void timer2_Tick(object sender, object e)
        {
            time_min.Text = (++timerCounterMin).ToString() + ":";
        }

        void timer_game_over_Tick(object sender, object e)
        {
            timer.Stop();
            timer2.Stop();
            timer_game_over.Stop();
            Grid_Zatemn_Fon.Visibility = Visibility.Visible;
        }

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            //
        }

        private void Back_of_MainPage_Click(object sender, RoutedEventArgs e)
        {
            this.Frame.Navigate(typeof(MainPage));
        }

        int Count_REZ_Ball = 0;
        private void Select_Answer_Click(object sender, RoutedEventArgs e)
        {
            Count_Ball.Text = (++Count_REZ_Ball).ToString();
        }
    }
}
